<?php

    require_once('init.php');    
    $panier = $_SESSION['client']->initPanier();
    require_once('header.php');
?>
    <h1 class="h1_panier">
        Récapitulatif du Panier
    </h1>
<?php
    $panier_details = $panier->getPanierDetails();
    $tva = Tva::rechercheTva(2);
    if(!empty($panier_details)) {
        echo    '<table class="table_panier" cellspacing="0px">
                    <thead>
                        <tr>
                            <th>Code Article</th>
                            <th>Nom</th>
                            <th>Quantité</th>
                            <th>Prix</th>
                        </tr>
                    </thead>
                    <tbody>';
        $totaux = $panier->getTotaux();
        foreach($panier_details as $pd) {
            echo        '<tr>
                            <td>
                                '.$pd->getProduit()->getReference().'
                            </td>
                            <td>
                                '.$pd->getProduit()->getLibelle().'
                            </td>
                            <td>
                                '.$pd->getQuantite().'
                            </td>
                            <td>
                                '.$pd->getPrix(false).' €
                            </td>
                        </tr>';
        }
        echo        '</tbody>
                    <tfoot>
                        <tr>
                            <td>
                                Total HT
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                '.$totaux[0].' €
                            </td>
                        </tr>
                        <tr>
                            <td>
                                TVA
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                '.($totaux[1] - $totaux[0]).' €
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Total TTC
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                '.$totaux[1].' €
                            </td>
                        </tr>
                    </foot>
                </table>
                
            <div class="bouton_panier">
                <a href="index.php" style="text-align:center;">
                    Continuer mes achats
                </a>
                <a href="confirmation.php" style="text-align:center;">
                    Valider mes achats
                </a>
            </div>';
    }
    

    
    
    
    
    
    
    require 'footer.php';

?>
